<!--
 * @desc:
 * @Author: 钟强
 * @Date: 2021-12-15 14:32:25
 * @LastEditors: 钟强
 * @LastEditTime: 2021-12-16 10:36:47
-->
<template>
  <el-config-provider :locale="store.getters.language === 'en' ? en : zhCn">
    <router-view></router-view>
  </el-config-provider>
</template>

<script setup>
import { useStore } from 'vuex'
import { generateNewStyle, writeNewStyle } from './utils/theme'
import { watchSwitchLang } from '@/utils/i18n'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import en from 'element-plus/lib/locale/lang/en'

const store = useStore()
generateNewStyle(store.getters.mainColor).then((newStyleText) => {
  writeNewStyle(newStyleText)
})

watchSwitchLang(() => {
  if (store.getters.token) {
    store.dispatch('user/getUserInfo')
  }
})
</script>

<style lang="scss" scoped>
</style>
